#include <bits/stdc++.h>
// 2025/02/17
// tag: string
// Author: Forever
using namespace std;

using int64 = int64_t;
signed main()
{
    int n;
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        if (s.size() > 10)
            cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
        else
            cout << s << endl;
    }
    return 0;
}